package bowlingScorekeeper;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;


public class MyFrame extends JFrame {

	
	public static void main(String[] args) {
		new MyFrame();
	}
	
	public MyFrame() {
		setLayout(new GridLayout(0, 1));
		
		JLabel label1 = new JLabel("I don't rotate");
		JLabel label2 = new RotateLabel("I rotate");
		
		add(label1);
		add(label2);

		setSize(100, 100);
		setVisible(true);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
	}
	
	private class RotateLabel extends JLabel {
		
		public RotateLabel(String text) {
			super(text);
		}
		
		@Override
		public void paintComponent(Graphics g) {
			Graphics2D gx = (Graphics2D) g;
			gx.rotate(.5, getX() + getWidth() / 2, getY() + getHeight() / 2); //Rotate 0.2 radians around the center of the label
			super.paintComponent(g);
		}
	}
}

